home *** CD-ROM | disk | FTP | other *** search
- _VISUAL BASIC AND WINDOWS 3.1_
- by Moshe Lichtman
-
-
- [LISTING ONE]
-
- Type RcResult ' RcResult structure
- SYGraph As syg ' Symbol Graph element
- wREsultsType As Integer ' Status of RcResult handling
- cSyv As Integer
- lpsyv As Long
- hSyv As Integer
- nBaseLine As Integer
- nMidLine As Integer
- hPenData As Integer
- rectboundink As RECTSHORT
- pntEnd As PointShort
- lprc As Long
- End Type
-
- Type syg ' Symbol Graph structure
- rgpntHotSpotsArray As PointArray ' "hot spot" array
- cHotSpot As Integer
- nFirstBox As Integer
- lRecogVal As Long
- lpSye As Long ' Pointer to first Symbol Element
- cSye As Integer ' Number of Symbol elements
- lpSyc As Long
- csyc As Integer
- End Type
-
- Type SYE ' Symbol element structure
- Syv As Long ' Symbol Value
- lRecogVal As Long
- cl As Integer
- iSyc As Integer
- End Type
-
- 'The following two functions copy data to/from Visual Basic strings
- 'and from/to memory pointed by long pointers.
- Declare Sub VBTypeToCPointer Lib "PENCNTRL.VBX" (lpSrc As Any, ByVal
- lpDest As Long, ByVal cb As Integer)
- Declare Sub CPointerToVBType Lib "PENCNTRL.VBX" (ByVal lpSrc As Long,
- lpDest As Any, ByVal cb As Integer)
-
-
-
-
- [LISTING TWO]
-
- Sub Process_cGestures
- Dim VBrc As RcResult
- Dim SyeTable() As SYE ' array of Symbol elements
- CPointerToVBType ByVal RcResult, VBrc, 80 'copy RcResult struct to VB var
- NumOfSymbols% = VBrc.SYGraph.cSye ' get number of Symbol elements
- lpSye& = VBrc.SYGraph.lpSye ' pointer to first Symbol Element
- ReDim SyeTable(NumOfSymbols%) ' re-define Symbol array
- ' copy Symbol elements
- CPointerToVBType ByVal lpSye&, SyeTable(0), NumOfSymbols% * 12
- If (NumOfSymbols% = 1) Then ' process only if single gesture
- Syv& = SyeTable(0).Syv
- SyvType& = Syv& \ &H10000 ' get Symbol type. Is it a gesture?
- If (SyvType& = SYVHI_GESTURE) Then ' if so, is it a circle-H gesture?
- If (Syv& = (SYV_CIRCLELOA + Asc("h") - Asc("a"))) Then
- HideCmd_Click ' hide menu-bar
- VBrc.wREsultsType = VBrc.wREsultsType Or RCRT_ALREADYPROCESSED
- End If ' mark to prevent further processing
- End If
- VBTypeToCPointer VBrc, ByVal RcResult, 80 ' update RcResult
- End If
- End Sub
-
-
-
- [LISTING THREE]
-
- ' DuplicatePenData() takes a handle to ink (hPenData or hInk) and returns a
- ' new hInk/hPenData that has a copy of the ink. NOTE: Whenever this function
- ' is used, a GlobalFree() call must be issued to release the memory.
- Declare Function DuplicatePenData Lib "PENWIN" (ByVal hPenData As
- Integer, ByVal gMemFlags As Integer) As Integer
-
- ' SendMessage() is the message sending function of the Windows 3.x API.
- Declare Function SendMessage Lib "USER" (ByVal hWnd As Integer, ByVal
- wMsg As Integer, ByVal wParm As Integer, ByVal lParam As Any) As Long
-
- Sub PayButton_Click ()
- Amount! = Val(DollarCtrl.text) + Val(CentCtrl.text) / 100
- balance = balance - Amount!
- If balance < 0 Then
- Beep ' warn user if insufficient funds
- MsgBox "Insufficient Funds - Check Cancelled", 0, "ERROR!"
- balance = balance + Amount!
- Else
- check.NumField = CheckNumLabel.Caption ' store last check, remarks
- check.RemarksField = RemarksCtrl.text ' and store ink field
- check.SignatureField = DuplicatePenData(SignatureCtrl.hInk, ByVal 0)
-
- PayToCtrl.text = "" ' initialize input fields
-
- PayButton.Enabled = False
- End Sub
-
- Sub ShowLastCmd_Click () ' "Show Last" command function
-
- lParam = check.SignatureField ' Force integer into long
- CheckNumLabel.Caption = check.NumField ' restore last check and
- ' retrieve ink from memory
- lRet = SendMessage(SignatureCtrl.hWnd, WM_HEDITCTL, HE_SETINKMODE, lParam)
- End Sub
-
-